#ifndef __COMPONENTH__
#define __COMPONENTH__

#include "DataStructureH/attributes.h"
// #include "baseactor.h"
// #include "containor.h"
#include "enum.h"
class Containor;
class Drawer;
class ScreenBuffer_t;
class Component
{
    friend class Updater;

  public:
    virtual void render() = 0;
    virtual void bindDrawer(Drawer* ptr_drawer) = 0;
    virtual Action_t Commit() = 0;
    virtual Action_t Rollback() = 0;
    virtual Action_t SetFather(Containor*) = 0;
    virtual void UpdateChildCoord(Component*, Component*, Component*, Component*) = 0;
    Action_t LocalCoordSet(const Coord_t& pos, const Coord_t& size)
    {
        LocalPos = pos;
        LocalSize = size;
        return 0;
    }
    Action_t LocalCoordSet(const CoordGroup& input)
    {
        LocalPos = input.pos;
        LocalSize = input.size;
        return 0;
    }
    virtual Action_t Zerolize() = 0;
    void setPos(SocketList pos) { posStatus = pos; }
    const SocketList& WhichSocket() const { return posStatus; }
    Containor* getFather() const
    {
        if (father ==
            (Containor*)(0xbaadf00dbaadf00d)) // for a Component that haven't ever been binded, it's father will become
                                              // this magic number(which means the mem is not initialized?)
            return nullptr;
        else
            return this->father;
    }

  protected:
    Component() : father(nullptr), ptr_drawer(nullptr), LocalPos(0, 0), LocalSize(0, 0) {}
    Component(Drawer* ptr) : ptr_drawer(ptr), LocalPos({0, 0}), LocalSize({2, 2}) {}
    Component(Drawer* ptr, Containor* father) : ptr_drawer(ptr), LocalPos({0, 0}), LocalSize({2, 2}), father(father) {}
    virtual ~Component() {};

    Containor* father;

    // private:
    bool bindPos{true};
    bool bindSize{true};
    Drawer* ptr_drawer;
    Coord_t LocalPos;
    Coord_t LocalSize;
    SocketList posStatus;
    // const int type{int(Clist::Component)};
};
#else

#endif